/**
 * 封装操作数据库的通用api
 */
const mq = require('mysql')
exports.base = (sqlname,sql,data,callback) => {
  const conn = mq.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: sqlname
  });
  conn.connect();
  conn.query(sql,data,function(err,res){
    if(err){
      console.log('发生错误' + err);
      return
    }
    callback(res) //回调函数
  })
}